<template>
  <div>
    <!-- 完本 -->
    <div class="container">
      <!-- 导航 -->
      <div class="nav">
        <router-link tag="h1" to="/boy">
          <a><i></i></a><span @click="$router.go(-1)">完本</span>
        </router-link>
        <div class="sex">
          <p>男生</p>
          <p>女生</p>
        </div>
        <div class="img">
          <a
            ><img src="../assets/img/search_black.gif" alt="" @click="jump"
          /></a>
          <van-cell @click="showPopup">
            <a><img src="../assets/img/bar.gif" alt="" /></a>
          </van-cell>
          <van-popup v-model="show" position="top" :style="{ height: '30%' }">
            <div class="guide-content">
              <ul>
                <router-link tag="li" to="/boy">
                  <i></i>
                  <p>首页</p>
                </router-link>
                <router-link tag="li" to="/page1">
                  <i></i>
                  <p>分类</p>
                </router-link>
                <router-link tag="li" to="/page2">
                  <i></i>
                  <p>排行榜</p>
                </router-link>
                <router-link tag="li" to="/page3">
                  <i></i>
                  <p>免费</p>
                </router-link>
                <router-link tag="li" to="/page4">
                  <i></i>
                  <p>完本</p>
                </router-link>
                <router-link tag="li" to="/userinfo">
                  <i></i>
                  <p>账户</p>
                </router-link>
              </ul>
            </div>
          </van-popup>
        </div>
      </div>
      <!-- 影视同期 -->
      <div class="module">
        <div class="module-header">
          <div class="left">影视同期</div>
          <div class="right">
            更多 <span class="iconfont icon-dayuhao"></span>
          </div>
        </div>
        <div class="list">
          <div class="content">
            <van-swipe :loop="false" :width="82" :show-indicators="false">
              <van-swipe-item
                v-for="item in limit_book_lists_two"
                :key="item.id"
              >
                <div class="item">
                  <div class="img">
                    <img :src="item.img" alt="" />
                  </div>
                  <div class="text">
                    <p>{{ item.name }}</p>
                    <p>{{ item.author }}</p>
                  </div>
                </div>
              </van-swipe-item>
            </van-swipe>
          </div>
        </div>
      </div>

      <!-- 大神完本 -->
      <div class="module">
        <div class="module-header">
          <div class="left">大神完本</div>
          <div class="right">
            更多 <span class="iconfont icon-dayuhao"></span>
          </div>
        </div>
        <div class="book" v-for="item in book_lists_three" :key="item.id">
          <div class="img">
            <img :src="item.img" alt="" />
          </div>
          <div class="text">
            <h4>{{ item.name }}</h4>
            <p>
              {{ item.brief }}
            </p>
            <div class="bottom">
              <div class="text_left">{{ item.type }} · {{ item.number }}</div>
              <div class="text_right">
                <p>{{ item.label_one }}</p>
                <p>{{ item.label_two }}</p>
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- 经典必读 -->
      <div class="module">
        <div class="module-header">
          <div class="left">经典必读</div>
          <div class="right">
            更多 <span class="iconfont icon-dayuhao"></span>
          </div>
        </div>
        <div class="book" v-for="item in book_lists_five" :key="item.id">
          <div class="img">
            <img :src="item.img" alt="" />
          </div>
          <div class="text">
            <h4>{{ item.name }}</h4>
            <p>
              {{ item.brief }}
            </p>
            <div class="bottom">
              <div class="text_left">{{ item.type }} · {{ item.number }}</div>
              <div class="text_right">
                <p>{{ item.label_one }}</p>
                <p>{{ item.label_two }}</p>
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- 畅销完本 -->
      <div class="module">
        <div class="module-header">
          <div class="left">畅销完本</div>
          <div class="right">
            更多 <span class="iconfont icon-dayuhao"></span>
          </div>
        </div>
        <div class="book" v-for="item in book_lists_four" :key="item.id">
          <div class="img">
            <img :src="item.img" alt="" />
          </div>
          <div class="text">
            <h4>{{ item.name }}</h4>
            <p>
              {{ item.brief }}
            </p>
            <div class="bottom">
              <div class="text_left">{{ item.type }} · {{ item.number }}</div>
              <div class="text_right">
                <p>{{ item.label_one }}</p>
                <p>{{ item.label_two }}</p>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!-- 底部 -->
      <div class="module selected">
        <div class="text" v-show="flag">
          <p>登录后获得更多特色功能·</p>
          <router-link tag="p" to="/userinfo">立即登录</router-link>
        </div>
      </div>
      <div class="footer-link">
        <div class="top">
          <p>QQ阅读</p>
          <p>红袖添香</p>
        </div>
        <div class="among">
          <p>客户端</p>
          <p>触屏版</p>
          <p>帮助与客服</p>
          <p>搜索</p>
        </div>
        <div class="footer-copy">
          <p>网站备案/许可证号：沪B2-20080046-1</p>
          <p>互联网宗教信息服务许可证 编号：沪（2022）0000022</p>
          <p>沪B2-20080046-1</p>
        </div>
      </div>
      <div class="content">
        <div class="img">
          <img src="../assets/img/fixed.png" alt="" />
          <div class="text">
            <p>安装起点读书客户端</p>
            <p>看更多正版好书</p>
          </div>
        </div>
        <div class="download">下载</div>
      </div>
    </div>
  </div>
</template>

<script>
import { getJsonData, getModuleToplistData, getFreeData } from "../api/home.js";
export default {
  data() {
    return {
      page_id: this.$route.query.id,
      limit_book_lists: [
        {
          id: 49,
          img: "https://bookcover.yuewen.com/qdbimg/349573/1034174315/150",
          name: "创造互联天道时代",
          author: "李鸿天",
        },
        {
          id: 50,
          img: "https://bookcover.yuewen.com/qdbimg/349573/1031529128/150",
          name: "死神之千年血战",
          author: "王刃西索",
        },
        {
          id: 51,
          img: "https://bookcover.yuewen.com/qdbimg/349573/1022928526/150",
          name: "星际争霸：泰伦帝国",
          author: "楠木笔芯",
        },
        {
          id: 52,
          img: "https://bookcover.yuewen.com/qdbimg/349573/1019401181/150",
          name: "篮球从呼吸法开始",
          author: "爱打球",
        },
        {
          id: 53,
          img: "https://bookcover.yuewen.com/qdbimg/349573/1032551288/150",
          name: "开局爆出熟练度面板",
          author: "成有道",
        },
        {
          id: 54,
          img: "https://bookcover.yuewen.com/qdbimg/349573/1033509773/150",
          name: "九叔世界之超级强化",
          author: "红尘大海",
        },
        {
          id: 55,
          img: "https://bookcover.yuewen.com/qdbimg/349573/1034214168/150",
          name: "崇祯欠了我十亿两",
          author: "远明不渐",
        },
        {
          id: 56,
          img: "https://bookcover.yuewen.com/qdbimg/349573/1033965414/150",
          name: "斗罗之掀翻诸神",
          author: "何为天人",
        },
      ],
      limit_book_lists_two: [
        {
          id: 61,
          img: "https://bookcover.yuewen.com/qdbimg/349573/84024/150",
          name: "回到明朝当王爷",
          author: "月关",
        },
        {
          id: 62,
          img: "https://bookcover.yuewen.com/qdbimg/349573/53269/150",
          name: "鬼吹灯（盗墓者的经历",
          author: "本物天下",
        },
        {
          id: 63,
          img: "https://bookcover.yuewen.com/qdbimg/349573/3347574/150",
          name: "从前有座灵剑山",
          author: "国王陛下",
        },
        {
          id: 64,
          img: "https://bookcover.yuewen.com/qdbimg/349573/2019/150",
          name: "诛仙（电视名：诛仙青云志）",
          author: "萧鼎",
        },
        {
          id: 65,
          img: "https://bookcover.yuewen.com/qdbimg/349573/2019/150",
          name: "诛仙（电视名：诛仙青云志）",
          author: "萧鼎",
        },
        {
          id: 66,
          img: "https://bookcover.yuewen.com/qdbimg/349573/2019/150",
          name: "诛仙（电视名：诛仙青云志）",
          author: "萧鼎",
        },
        {
          id: 67,
          img: "https://bookcover.yuewen.com/qdbimg/349573/2019/150",
          name: "诛仙（电视名：诛仙青云志）",
          author: "萧鼎",
        },
        {
          id: 56,
          img: "https://bookcover.yuewen.com/qdbimg/349573/2019/150",
          name: "诛仙（电视名：诛仙青云志）",
          author: "萧鼎",
        },
      ],
      book_lists: null,
      book_lists_two: null,
      book_lists_three: null,
      book_lists_four: null,
      book_lists_five: null,
      item_lists: null,
      account_num: null,
      flag: true,
      module_toplist_lists: null,
      free_lists: [
        {
          id: 1,
          img: "https://bookcover.yuewen.com/qdbimg/349573/1033850979/150",
          name: "盗墓：一剑天门开，怒劈青铜门",
          author: "九三废废",
        },
        {
          id: 2,
          img: "https://bookcover.yuewen.com/qdbimg/349573/1034076052/150",
          name: "斗罗之辅助厉害",
          author: "五月的黑",
        },
        {
          id: 3,
          img: "https://bookcover.yuewen.com/qdbimg/349573/1034339563/150",
          name: "联盟：我真不是绝活哥",
          author: "青石子",
        },
        {
          id: 4,
          img: "https://bookcover.yuewen.com/qdbimg/349573/1034264221/150",
          name: "四合院：从相亲被截胡开始",
          author: "大猫怕水",
        },
        {
          id: 5,
          img: "https://bookcover.yuewen.com/qdbimg/349573/1031857991/150",
          name: "开局忽悠校花，结果一胎俩娃？",
          author: "会讲故事",
        },
        {
          id: 6,
          img: "https://bookcover.yuewen.com/qdbimg/349573/1033170468/150",
          name: "重生港综当枭雄",
          author: "钟离昩",
        },
        {
          id: 7,
          img: "https://bookcover.yuewen.com/qdbimg/349573/1033170468/150",
          name: "重生港综当枭雄",
          author: "钟离昩",
        },
      ],
      show: false,
    };
  },
  methods: {
    account() {
      this.account_num = window.localStorage.getItem("token");
      if (this.account_num) {
        this.flag = false;
      } else {
        this.flag = true;
      }
    },
    jump() {
      this.$router.push({ path: "/search" });
    },
    showPopup() {
      this.show = true;
    },
  },
  created() {
    this.account();
    getJsonData().then((data) => {
      this.item_lists = data.data;
    });
    getModuleToplistData().then((data) => {
      this.module_toplist_lists = data.data;
    });
    getFreeData().then((data) => {
      console.log(data);
      this.book_lists = data.data;
      this.book_lists_two = data.data_two;
      this.book_lists_three = data.data_three;
      this.book_lists_four = data.data_four;
      this.book_lists_five = data.data_five;
    });
  },
};
</script>

<style lang="scss" scoped>
// 分类
.container {
  background-color: #f0f1f2;
}
.module-toplist {
  background-color: #fff;
  display: flex;
  margin-bottom: 12px;
  .img {
    position: relative;
    h2 {
      position: absolute;
      top: 56px;
      left: 14px;
      font-size: 31px;
      color: #fff;
      font-weight: bold;
    }
    .fixed {
      position: absolute;
      bottom: 31px;
      left: 50px;
      width: 24px;
      height: 24px;
    }
    img {
      width: 120px;
      height: 180px;
    }
  }
  ul {
    width: 70%;
    li {
      display: flex;
      width: 90%;
      margin-left: 16px;
      height: 36px;
      line-height: 36px;
      font-size: 15px;
      color: #33373d;
      font-weight: bold;
      .num {
        margin-right: 5px;
      }
    }
  }
}
.novel {
  display: flex;
  width: 90%;
  justify-content: space-between;
  border-bottom: 1px solid #f0f1f2;
}
/* 底部 */
.selected {
  background-color: #fff;
  .text {
    margin-top: 0;
    padding: 16px 0;
  }
}
a {
  text-decoration: none;
  color: #000;
}

/* 导航 */
.nav {
  display: flex;
  padding: 9px 12px;
  justify-content: space-between;
  background-color: #fff;
  h1 {
    height: 26px;
    line-height: 26px;
    font-size: 18px;
    color: #ee2737;
    font-weight: bold;
    display: block;
    display: flex;
    span {
      font-size: 14px;
      color: #33373d;
      font-weight: normal;
      margin-left: 16px;
      margin-top: 1px;
    }
    i {
      display: block;
      width: 9px;
      height: 18px;
      background: url("../assets/img/arrow_da.gif") center center no-repeat;
      margin-top: 5px;
    }
  }
  .sex {
    display: flex;
    height: 24px;
    line-height: 24px;
    border: 1px solid #ed424b;
    p {
      &:nth-child(1) {
        padding: 0 12px;
        background-color: #ed424b;
        font-size: 12px;
        color: #fff;
      }
      &:nth-child(2) {
        padding: 0 12px;
        background-color: #fff;
        font-size: 12px;
        color: #ed424b;
      }
    }
  }
  .img {
    display: flex;
    img {
      width: 16px;
      height: 16px;
      padding-top: 6px;
    }
    a {
      &:nth-child(1) {
        img {
          margin-right: 20px;
        }
      }
    }
  }
}

/* 内容 */
.item {
  margin-left: 16px;
  &.con {
    border-bottom: 1px solid #f0f1f2;
  }
  .top {
    display: flex;
    height: 40px;
    line-height: 40px;
    justify-content: space-between;
    border-bottom: 1px solid #f0f1f2;
    p {
      &:nth-child(1) {
        font-size: 15px;
        color: #33373d;
        font-weight: bold;
        span {
          font-size: 14px;
          color: #969ba3;
          margin-left: 5px;
          font-weight: normal;
        }
      }
      &:nth-child(2) {
        margin-right: 17px;
      }
    }
  }
  ul {
    display: flex;
    // justify-content: space-between;
    padding-right: 13px;
    padding-top: 12px;
    padding-bottom: 5px;
    flex-wrap: wrap;
    li {
      height: 27px;
      line-height: 27px;
      font-size: 14px;
      margin-right: 10px;
      color: #969ba3;
      border: 1px solid #969ba3;
      border-radius: 10px;
      padding: 0 8px;
      border-radius: 13px;
      margin-bottom: 12px;
    }
  }
}
/* 底部 */
.selected {
  padding-bottom: 20px;
  // border-bottom: 2px solid #f0f1f2;
  margin-bottom: 0;
  .img {
    width: 100%;
    display: flex;
    justify-content: space-between;
    margin-top: 16px;
    img {
      width: 48%;
    }
  }
  .text {
    display: flex;
    justify-content: center;
    font-size: 14px;
    p {
      &:nth-child(2) {
        color: #4284ed;
      }
    }
  }
}
.footer-link {
  background-color: #fff;
  padding-top: 22px;
  padding-bottom: 24px;
  .top {
    p {
      width: 50%;
      text-align: center;
      font-size: 14px;
      color: #969ba3;
    }
  }
  .among {
    margin-top: 34px;
    p {
      width: 25%;
      text-align: center;
      font-size: 14px;
      color: #969ba3;
    }
  }
  .footer-copy {
    text-align: center;
    font-size: 12px;
    color: #969ba3;
    margin-top: 20px;
  }
}
.footer-link .top,
.footer-link .among {
  display: flex;
}
.content {
  background-color: #f6f7f9;
  padding: 0 16px 17px 16px;
  display: flex;
  justify-content: space-between;
  .img {
    display: flex;
    margin-top: 12px;
    img {
      width: 36px;
      height: 36px;
    }
    .text {
      margin-left: 12px;
      p {
        &:nth-child(1) {
          font-size: 14px;
          color: #33373d;
        }
        &:nth-child(2) {
          font-size: 12px;
          color: #969ba3;
        }
      }
    }
  }
  .download {
    margin-top: 16px;
    font-size: 14px;
    padding: 7px 16px;
    background-color: #ed424b;
    color: #fff;
    border-radius: 18px;
  }
}
a {
  text-decoration: none;
  color: #000;
}

// 畅销精选
.module {
  padding: 0 16px;
  margin-bottom: 11px;
  background-color: #fff;
  .book {
    display: flex;
    padding-bottom: 16px;
    border-bottom: 2px solid #f0f1f2;
    margin-top: 10px;
    img {
      width: 66px;
      height: 88px;
    }
    .text {
      margin-left: 6px;
      h4 {
        height: 22px;
        line-height: 22px;
        color: #33373d;
        font-weight: bold;
      }
      & > p {
        font-size: 14px;
        color: #969ba3;
        word-break: break-all;
        text-overflow: ellipsis;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        margin-top: 6px;
      }
      .bottom {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 4px;
        .text_left {
          display: flex;
          font-size: 14px;
          color: #969ba3;
        }
        .text_right {
          display: flex;
          color: #adadad;
          font-size: 12px;
          margin-top: 1px;
          & > p {
            height: 18px;
            line-height: 18px;
            padding: 0 4px;
            background-color: #f5f5f5;
            border-radius: 3px;
            &:nth-child(1) {
              margin-right: 4px;
            }
          }
        }
      }
    }
  }
}
.module-header {
  display: flex;
  justify-content: space-between;
  padding: 20px 0 10px 0;
  .left {
    font-size: 16px;
    border-left: 2px solid #ed424b;
    padding: 0 8px;
    font-weight: 500;
    color: #33373d;
    font-weight: bold;
  }
  .right {
    font-size: 14px;
    color: #969ba3;
  }
}

// 免费
.module {
  padding: 0 16px;
  margin-bottom: 11px;
  background-color: #fff;
  .module-header {
    display: flex;
    justify-content: space-between;
    padding: 20px 0 10px 0;
    align-items: center;
    .left {
      & > .time {
        margin-left: 0;
        border-radius: 3px;
        background-color: #33373d;
        color: #ffffff;
        &:nth-child(1) {
          background-color: #ed424b;
          color: #faf3ff;
        }
      }
    }
    .left {
      font-size: 16px;
      border-left: 2px solid #ed424b;
      padding: 0 8px;
      font-weight: 500;
      color: #33373d;
      font-weight: bold;
    }
    .right {
      font-size: 14px;
      color: #969ba3;
    }
  }
  .list {
    padding-bottom: 16px;
    .content {
      padding: 0;
      background-color: #ffffff;
      .van-swipe {
        .van-swipe-item {
          // width: 100%;
          //   margin-right: 16px;
          .item {
            margin-left: 0;
            .img {
              width: 66px;
              height: 88px;
              position: relative;
              margin-top: 0;
              img {
                width: 100%;
                height: 100%;
              }
              em {
                position: absolute;
                left: 0;
                top: 7px;
                font-size: 10px;
                line-height: 11px;
                font-style: normal;
                background-color: #4284ed;
                color: #fff;
                transform: rotate(-45deg);
              }
            }
            .text {
              width: 100%;
              line-height: 16px;
              font-size: 12px;
              color: #33373d;
              p {
                &:nth-child(1) {
                  margin: 6px 0;
                  height: 32px;
                  overflow: hidden;
                }
                &:nth-child(2) {
                  font-size: 13px;
                  color: #969ba3;
                }
              }
            }
          }
        }
      }
    }
  }
}

// 排行榜

// 大神
/* 白金列表 */
.book_author {
  display: flex;
  margin-top: 18px;
  .img {
    position: relative;
    img {
      width: 48px;
      height: 48px;
      border-radius: 50%;
    }
    & > p {
      position: absolute;
      font-size: 12px;
      color: #fff;
      bottom: 24px;
      left: 0;
      right: 0;
      margin: auto;
      background-color: #b3a7ff;
      width: 38px;
      height: 14px;
      text-align: center;
      line-height: 14px;
      border-radius: 8px;
      &.dashen {
        background-color: #ed424b;
      }
    }
  }
}
.book-cell {
  margin-left: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid #f1f2f3;
  padding-bottom: 22px;
  h4 {
    font-size: 16px;
    color: #33373d;
    font-weight: bold;
  }
  p {
    width: 100%;
    font-size: 14px;
    color: #969ba3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 8px;
  }
}

// 导航栏的显示与隐藏
.van-popup {
  text-align: center;
  ul {
    display: flex;
    flex-wrap: wrap;
    li {
      width: 33.3%;
      text-align: center;
      margin-top: 30px;
      &:nth-child(2) {
        i {
          background-position: -63px -28px;
          width: 24px;
          height: 24px;
          background-size: 87px 87px;
        }
      }
      &:nth-child(3) {
        i {
          background-position: 0 0;
          width: 27px;
          height: 26px;
          background-size: 87px 87px;
        }
      }
      &:nth-child(4) {
        i {
          background-position: 0 -30px;
          width: 26px;
          height: 26px;
          background-size: 87px 87px;
        }
      }
      &:nth-child(5) {
        i {
          background-position: 0 -60px;
          width: 20px;
          height: 27px;
          background-size: 87px 87px;
        }
      }
      &:nth-child(6) {
        i {
          background-position: -63px 0;
          width: 24px;
          height: 24px;
          background-size: 87px 87px;
        }
      }
      i {
        margin: 0 auto;
        display: block;
        background: url("https://qidian.gtimg.com/qdm/icon/common/sprite@2x.f5569.png");
        background-position: -31px 0;
        background-size: 87px 87px;
        width: 28px;
        height: 25px;
      }
      p {
        margin-top: 10px;
      }
    }
  }
}
.van-cell {
  padding: 0;
}
.nav .img a:nth-child(1) img {
  margin-right: 0;
}
.nav .img a:nth-child(1) {
  margin-right: 20px;
}
</style>
